package cn.swust.score.dao;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; 
import org.apache.ibatis.annotations.Update;  
import cn.swust.score.pojo.Candidate;
import cn.swust.score.pojo.QueryCandidate;

@Mapper
public interface CandidateDao {
    int delById(Integer id);

    int save(Candidate record);

    Candidate getById(Integer id);

    int editById(Candidate record);
    
    List<Candidate> list(QueryCandidate param);  
    
	Candidate getNext(@Param("scoreInfoId") Integer scoreInfoId, @Param("sort") Integer sort);
	
	@Select("select average from candidate_stag_info where candidate_id=#{candidateId} and stage_id=#{stageId}")
	int getStageScore(@Param("candidateId")int candidateId,@Param("stageId") int stageId);


	@Select("select count(0) from candidate where score_info_id = #{scoreInfoId}  ")
	int countCandidate(@Param("scoreInfoId") Integer scoreInfoId ); 
	
	@Select("select count(0) from candidate where score_info_id = #{scoreInfoId} and school != #{school}")
	int countScore(@Param("scoreInfoId") Integer scoreInfoId, @Param("school") String  school);

	@Update("update candidate set total_score = #{totalScore},ranking =#{ranking} where id = #{id}")
	int editRankById(Candidate record);

	
}